<?php

namespace App\Controllers;

class writer extends BaseController {

    public function getshowme($id) {
        $poet = new \App\Models\poet();
        $record = $poet->find($id);
        $parser = \Config\Services::parser();
        $fields = [
            'title' => 'writer',
            'heading' => 'Introduction to Writers',
            'footer' => 'Copyright LuGuanYu'
        ];
        $table = new \CodeIgniter\View\Table();
        $table->addRow('id', $record['id']);
        $table->addRow('name', $record['name']);
        $table->addRow('Times', $record['Times']);
        $table->addRow('MainWorks', $record['MainWorks']);
        $table->addRow('DateOfBirth', $record['DateOfBirth']);
        $table->addRow('DateOfDeath', $record['DateOfDeath']);
        $table->addRow('link', $record['link']);
        $table->addRow('image', '<img height="100px" src="/image/' . $record['image'] . '">');
        $template = [
            'table_open' => '<table cellpadding="5px">',
            'cell_start' => '<td style="border: 1px solid #dddddd;">',
            'row_alt_start' => '<tr style="background-color:#dddddd">',
        ];
        $table->setTemplate($template);
        return $parser->setData($fields)
                        ->render('templates\top') .
                $table->generate() .
                        $parser->setData($fields)
                        ->render('templates\bottom');
    }

}
